package com.eiletxie.springcloud.config;

import feign.Logger;
import feign.Request;
import feign.RequestInterceptor;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author EiletXie
 * @Since 2020/3/11 15:50
 */
@Configuration
public class FeignConfig {

    @Bean
    Logger.Level feignLoggerLevel() {
        return  Logger.Level.FULL;
    }

    /**
     * 设置对应的超时时间问题
     * 连接超时时间  和 读取超时时间
     * public Options(int connectTimeoutMillis, int readTimeoutMillis) {
     */
    @Bean
    public Request.Options getOption(){
         // public Options(int connectTimeoutMillis, int readTimeoutMillis) {
        return new Request.Options(5000,5000);
    }

    /**
     * 配置对应的统一过滤器 进行角色的 jwt 验证 添加验证权限
     */
    @Bean
    public OpenFeignRequestInterceptor openFeignRequestInterceptor(){
        return  new OpenFeignRequestInterceptor();
    }

    @Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
        //可以自己添加对应的请求头
        return new BasicAuthRequestInterceptor("user", "password");
    }


}
